package com.haolp.sys.controller;

import com.haolp.sys.common.vo.JsonResultVO;
import com.haolp.sys.dao.SysRoleDao;
import com.haolp.sys.pojo.SysRole;
import com.haolp.sys.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 小李
 * @version 1.0
 * @date 2021/10/11 9:15
 */
@RestController
@RequestMapping("/role/")
public class SysRoleController {
    @Autowired
    private SysRoleService sysRoleService;
    @RequestMapping("doFindRoles")
    public JsonResultVO doFindRoles(){
        return new JsonResultVO(
                sysRoleService.findObjects());
    }


    @RequestMapping("doFindObjectById")
    public JsonResultVO doFindObjectById(Integer id){
        return new JsonResultVO(
                sysRoleService.findObjectById(id));

    }
    @RequestMapping("doUpdateObject")
    public JsonResultVO doUpdateObject(SysRole entity,Integer[] menuIds){
        sysRoleService.updateObject(entity, menuIds);
        return new JsonResultVO("update ok");
    }

    @RequestMapping("doDeleteObject")
    public JsonResultVO doDeleteObject(Integer id){
        sysRoleService.deleteObject(id);
        return new JsonResultVO("delete ok");

    }
    @RequestMapping("doSaveObject")
    public JsonResultVO doSaveObject(SysRole entity, Integer[] menuIds) {
        sysRoleService.saveObject(entity, menuIds);
        return new JsonResultVO("insert ok");
    }


    @RequestMapping("doFindPageObjects")
    public JsonResultVO doFindPageObjects(String username, Integer pageCurrent) {

        return new JsonResultVO(sysRoleService.findPageObjects
                (username, pageCurrent));

    }
}
